# Maintainer: Peter Budai <peterbudai at hotmail dot com>

_realname=pugixml
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.7
pkgrel=1
pkgdesc="Light-weight, simple and fast XML parser for C++ with XPath support (mingw-w64)"
arch=('any')
url="http://pugixml.org/"
license=("GPL")
depends=()
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-gcc"
  "${MINGW_PACKAGE_PREFIX}-cmake"
)

source=( http://github.com/zeux/pugixml/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz
      CMakelist-deploy-in-subdirs.patch)
sha256sums=('FBE10D46F61D769F7D92A296102E4E2BD3EE16130F11C5B10A1AAE590EA1F5CA'
            '45166C952672D468D994276AB661AA90D7489410E5B86FE3E425BD8DA807857A')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  patch -Np1 -i "${srcdir}/CMakelist-deploy-in-subdirs.patch"
}


build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    -DBUILD_SHARED_LIBS=ON \
    ../${_realname}-${pkgver}/scripts

  make
}


package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install
}